//
//  AnswerDetailBottomView.m
//  OnionHome
//
//  Created by fengjie on 2019/9/24.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "AnswerDetailBottomView.h"
#import "AnswerInvitedRecomendLocalVC.h"

@implementation AnswerDetailBottomView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}
-(void)oneBtnAction:(UIButton *)button{
    button.selected = !button.selected;
    
}
-(void )createUI{
    kWeakSelf(weakSelf);

    UIButton * oneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [oneBtn setImage:IMAGE_NAMED(@"五角星") forState:UIControlStateNormal];
    [oneBtn setImage:IMAGE_NAMED(@"五角星_selecet") forState:UIControlStateSelected];
    [oneBtn setTitle:@"关注" forState:UIControlStateNormal];
    [oneBtn setTitleColor:UIColorFromRGB(0x454F44) forState:UIControlStateNormal];
    oneBtn.titleLabel.font = SYSTEMFONT(14);
    [oneBtn addTarget:self action:@selector(oneBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [oneBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4, 0, -4)];
    
    
    UIButton * twoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [twoBtn setImage:IMAGE_NAMED(@"home_mesae") forState:UIControlStateNormal];
    [twoBtn setTitle:@"提问" forState:UIControlStateNormal];
    [twoBtn setTitleColor:UIColorFromRGB(0x454F44) forState:UIControlStateNormal];
    twoBtn.titleLabel.font = SYSTEMFONT(14);
    [twoBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4, 0, -4)];

    
    [twoBtn addActionHandler:^{
        [[weakSelf getCurrentViewController].navigationController pushViewController:[AnswerInvitedRecomendLocalVC new] animated:YES];
    }];


    UIButton * thereBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [thereBtn setImage:IMAGE_NAMED(@"xiepinglun") forState:UIControlStateNormal];
    [thereBtn setTitle:@"写回答" forState:UIControlStateNormal];
    [thereBtn setTitleColor:UIColorFromRGB(0x009966) forState:UIControlStateNormal];
    thereBtn.titleLabel.font = SYSTEMFONT(14);
    [thereBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4, 0, -4)];

    
    [thereBtn addActionHandler:^{
        [weakSelf writeAnswerAction];
    }];

    [self addSubview:oneBtn];
    [self addSubview:twoBtn];
    [self addSubview:thereBtn];

    [oneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(36);
        make.top.mas_equalTo(16);
        make.bottom.mas_equalTo(-16);
    }];
    [twoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(16);
        make.bottom.mas_equalTo(-16);
    }];
    [thereBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-36);
        make.top.mas_equalTo(16);
        make.bottom.mas_equalTo(-16);
    }];

}

/// 写回答
-(void)writeAnswerAction{
    AskQuestionsController * askVC = [AskQuestionsController new];
    askVC.type = AskQuestionsAnswer;
    [[self getCurrentViewController].navigationController pushViewController:askVC animated:YES];
}
@end
